<template>
  <div id="asyncRoutesConfigAdd">
    <AsyncRoutesConfigForm @submitRoutesConfig="submitRoutesConfig" :showRule="showRule" />
  </div>
</template>

<script>
import AsyncRoutesConfigForm from './asyncRoutesConfigForm.vue';
import {
  createMenu
} from '@/assets/request/api.js';
export default {
  name: "asyncRoutesConfigAdd",
  data() {
    return {
      showRule: {}
    };
  },
  methods: {
    submitRoutesConfig(routesInfo) {
      let parentChildren = this.$route.params.children
      if(parentChildren) {
        routesInfo.orderBy = parentChildren[parentChildren.length - 1].orderBy + 100    // 随意即可， 拖拽菜单 orderBy 会重新刷新
      }
      routesInfo.parentId = this.$route.params.id
      createMenu(routesInfo).then(res => {
        this.$message({
          message: '添加成功',
          type: 'success'
        });
        this.$router.go(-1)
      }).catch(err => {
        this.$message({
          message: err.message,
          type: 'error'
        });
      })
    }
  },
  mounted() {
    this.showRule = this.$route.params
  },
  components: { AsyncRoutesConfigForm }
}
</script>

<style scoped lang="scss">

 
</style>
